Skip to main content

All Questions

2votes
3answers
284views

How do I model this scenario so that it adheres to OOP principles?

I have a Slide class with subclasses referring to the different types of slides (IntroSlide, SummarySlide, etc.): abstract class Slide { String slideType; final String title; final String ...
Hello's user avatar
-2votes
3answers
205views

Class inheritance design with protected methods and run time base handlers

Using C#, I got a class called BaseConfigurations which handles CRUD operations. This class also contains a protected method which is used inside the CRUD handling methods: public class ...
CodeMonkey's user avatar
24votes
11answers
8kviews

Is it logical to not use inheritance because the function is critical?

Our codebase has a typical base-class with a ton of sub-classes. The base-class already has many default functions for the sub-classes. However, one particular function has the same verbatim ...
Zack Light's user avatar
2votes
2answers
290views

Pattern for a base class to do pre-validation and/or post-processing on a deriving class's overridden method?

I have the following pattern repeating itself in multiple places: abstract class Database { void connect() { this.setStatus( CONNECTING ) try { await this.realConnect() } catch ...
Mahi's user avatar
  • 406
1vote
1answer
192views

Is it an acceptable pattern to put derived classes inside an abstract base class in Java?

Suppose I have some Java code such as the following (in this case, the use of the name "interaction" is referring to interacting with an object in a video game): public abstract class ...
micheal65536's user avatar
0votes
1answer
102views

How to refactor parallel inheritance tree?

I have a (php) program, which must change yearly. This program calculates tax for every year and there are sometime changes in requirements. First, the user fills their incomes, expenses, etc. Then ...
nrob's user avatar
  • 111
0votes
1answer
294views

Exposing only the getters of a singleton interface in C++

I've got a file in my includes folder, which is the folder I expose, that isn't used externally and isn't supposed to be used too. When I noticed that and tried to remove it - I noticed that it's ...
RedYoel's user avatar
0votes
3answers
977views

How to handle subclasses needing different method signatures for the overriden function?

I have an abstract class that represents chess pieces, it has an abstract method isMoveValid(Square futurePosition, PieceColor color) which checks if the piece moving to that square is valid or not, ...
Yoh's user avatar
  • 51
1vote
2answers
298views

How to design relationships with constraints on subclass type?

I'm developing a full-stack Rest application following a narrative description of a working context. There is a class Job with two subclasses Job_A and Job_B. Job_A produces Report_A while Job_B ...
Wippo's user avatar
0votes
2answers
601views

How to solve an issue when a decorator needs variables from the base class?

I have a service class that does some magic. I want to introduce a new type of functionality - raise an event. I am absolutely sure that decorator pattern is great for this scenario. The problem is ...
pro100tom's user avatar
0votes
1answer
269views

Wrapping the UI framework

I want to write an application where I would delegate certain functionalities to 3rd party libraries. To make sure the code remains modular, I want to put these libraries behind an interface so I can ...
yah_nosh's user avatar
-1votes
1answer
899views

Subclasses with same behaviour but different attributes for different inputs

Say I have two object types of the same interface MyObj (I am using python in this project so I will use the same for the explanation) class Foo(MyObj): a = [5, 10] class Bar(MyObj): a = [[1, ...
doca's user avatar
  • 255
1vote
2answers
1kviews

Concept/Design question: Alternatives to switch/conditional statements and Enums

I am practicing design patterns and OO concepts such as inheritance in java and I'm writing an application that represents a vending machine. I have two questions focused on ideal structure and design ...
Bob Jones's user avatar
2votes
1answer
334views

Composition or Inheritance for classes with almost similar implementations but different input and outputs for methods?

I have the following classes, which have quite similar method implementations. Only the classes' method inputs and outputs seem to be of different types. When I put it like this, it sounds like a case ...
AnOldSoul's user avatar
2votes
1answer
243views

How can I enforce that decorator pattern is complete at compile time?

I have a C++ class (Class D) that is a decorator of another class (Class B). Class D inherits from B and also requires an instance of B to construct that it keeps track of. Class D overrides all ...
Alexis Winters's user avatar

153050per page
close